﻿// *********************************************************
// 
//     Copyright (c) Microsoft. All rights reserved.
//     This code is licensed under the Apache License, Version 2.0.
//     THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//     ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//     IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//     PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
// 
// *********************************************************

using System.Globalization;
using Bio.Util;

namespace Bio.Distributions.Converters
{
    /// <summary>
    /// Class which converts from string to double
    /// </summary>
    public class StringToDoubleConverter : ValueConverter<string, double>
    {
        /// <summary>
        /// Create instance of StringToDoubleConverter class. 
        /// </summary>
        public StringToDoubleConverter() : base(c => 
            double.Parse(c.Trim(), CultureInfo.InvariantCulture), c => c.ToString(CultureInfo.InvariantCulture)) { }
    }
}
